#ifndef STUDY_WIDGET_BOTTOM_H
#define STUDY_WIDGET_BOTTOM_H

#pragma once

#include <QWidget>
#include <QPropertyAnimation>
#include <QDebug>

#define HOUR_HEIGHT				15			// 小时刻度线高度;
#define MINUTE_HEIGHT			10			// 分钟刻度线高度;
#define INTERVAL_DISTANCE		6			// 分钟间隔距离;
#define MOVE_STEP_DISTANCE		20			// 鼠标单击移动步长;

#define MAX_SCALE_FACTOR		8			// 最大放大比例;
#define MIN_SCALE_FACTOR		1			// 最小放大比例;

#define ANIMATION_DURATION		800			// 动画时长;

#define TOTLE_TIME				24			// 时间轴时长;

class study_widget_bottom : public QWidget
{
    Q_OBJECT
public:
    explicit study_widget_bottom(QWidget *parent = 0);
    void setScaleSmall();   // 缩小;
    void setScaleBig();     // 放大;
    void resetTimeLine();   // 重置时间轴;
private:
    void paintEvent(QPaintEvent *event);
    void drawOneHour(QPainter* painter, int hour);// 绘制每一个小时的时间轴;
    int drawStudyHour(QPainter *painter, int hour, qint64 time_bit);

    // 操作事件;
    void mouseMoveEvent(QMouseEvent* event);
    void mousePressEvent(QMouseEvent* event);
    void mouseReleaseEvent(QMouseEvent* event);
    void resizeEvent(QResizeEvent *event);
    void adjustCurrentScale();

    QTime getCurrentTime(); // 获取当前时间;
    QString getCurrentStrTime();
    int getCurrentScaleFactor();// 获取当前放缩倍数;
private:

    int m_transformX;           // 偏移量;
    int m_transformBeforeX;     // 偏移量备份值;
    bool m_isMousePressed;      // 鼠标是否按下;
    bool m_isMouseMoved;        // 鼠标是否按下之后移动;
    int m_timeInterval;         // 当前时间间距;
    int m_currentScaleFactor;   // 当前放大倍数;
    int m_currentMouseStepDistance; // 当前鼠标点击移动步长;
    int m_centerX;              // 窗口中心点X坐标;
    bool m_isFirstSet;          // 是否是第一次设置窗口宽度;
    QPoint m_pressPoint;        // 鼠标按下坐标;
    QPropertyAnimation *m_adjustScaleAnimation;    // 放大缩小动画;
    QString m_strCurrentTime;   // 保存当前时间轴时间;
signals:

public slots:
    void m_adjustScaleAnimationValueChanged(const QVariant &value);
    void m_adjustScaleAnimationFinished();
    void updateSelectedDate();
    void onStyStatusChanged(qint64);
};

#endif // STUDY_WIDGET_BOTTOM_H
